package net.hn.hnms.sys.common.core.domain;

import lombok.Data;

@Data
public class ApiResult<T> {
    private String iamRequestId;
    private String uid;

    private String orgId;
    private String resultCode;
    private String message;
    private T data;

    public ApiResult() {
    }

    public ApiResult(String iamRequestId, String uid,String orgId, String resultCode, String message) {
        this.iamRequestId = iamRequestId;
        this.uid = uid;
        this.orgId = orgId;
        this.resultCode = resultCode;
        this.message = message;
    }

    public static <T> ApiResult<T> success(String iamRequestId, String uid,String orgId) {
        return new ApiResult<>(iamRequestId, uid, orgId, "0", "success");
    }

    public static <T> ApiResult<T> failure(String iamRequestId,String resultCode, String message) {
        return new ApiResult<>(iamRequestId, "", "", resultCode, message);
    }

    public static <T> ApiResult<T> ok(T data) {
        ApiResult<T> result = new ApiResult<>(null, null,null, "0", "success");
        result.setData(data);
        return result;
    }
}

